package leetcode.code153;

public class SearchBinary {

	public int search(int[] arr, int target) {
		int l = 0;
		int r = arr.length-1;
		int m = 0;
		while (l < r) {
			m = (l + r) / 2;
			if (arr[m] < target) {
				l = m + 1;
			} else {
				r = m - 1;
			}
		}
		System.out.println(l + " " + m + " " + r);
		return l;
	}

	public static void main(String[] args) {
		SearchBinary sb = new SearchBinary();
		int[] arr1 = new int[] { 1, 3, 5, 7, 9, 11 };
		int[] arr2 = new int[] { 1, 3, 5, 7, 9, 11, 13 };
		sb.search(arr1, 5);
		sb.search(arr2, 5);
		sb.search(arr1, 2);
		sb.search(arr2, 2);
	}
}
